import { JSONSchemaType } from "ajv";
import { IMiddleware } from "koa-router";

import { ArticleLog } from "../model";
import { validateQuery } from "../middleware/validate";
import { pageValidator } from "./base";
import { ajv } from "../util/ajv";

interface GetArticleLogs {
  current: number;
  limit: number;
}

const getArticleLogsSchema: JSONSchemaType<GetArticleLogs> = {
  type: "object",
  properties: {
    current: {
      type: "number"
    },
    limit: {
      type: "number"
    }
  },
  required: ["current", "limit"]
};
ajv.addSchema(getArticleLogsSchema, "getArticleLogs");

// 获取所有文章记录
export const getArticlesValidator: IMiddleware[] = [
  validateQuery("getArticleLogs"),
  pageValidator()
];

